Skip to main content

Handling Falsy types

Hooks in useDapp support handling "falsy" values in most parameters.

export type Falsy = false | 0 | '' | null | undefined

If you pass one of these types to a call, it will return undefined without making blockchain query. This allows us to conditionally make a call if a parameter is not known ahead of time, without breaking the Rules of Hooks.

Example

const {account} = useEthers() // account is of type "string | undefined"
const balance = useEtherBalance(account) // Will start making queries once account is defined